{% extends "../templates/ajax/main_content_base.html" %} 
{% block intro %}{% endblock %}
{% block page_name %}my_group{% endblock %}
{% block content %}

<div class="notification information png_bg">
	<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
	<div>
		您还没有加入任何小组，您可以在这里创建一个新的小组，或者您可以在<a onclick="$('#main-content').load('group_list');return false;" href="#">所有小组</a>中选择一个加入。
	</div>
</div>
<div class="content-box">
	<div class="content-box-header">
		<h3>创建小组</h3>
	</div>
	<!-- End .content-box-header -->

	<div class="content-box-content">

		<div class="tab-content default-tab">

			<h4></h4>
			<form id="create-group-form" action="create_group" method="post">

				<fieldset>
					<!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->

					<p>
						<label>小组名称</label> <input
							class="text-input small-input required" type="text" id="small-input"
							name="name" />
						<!-- Classes for input-notification: success, error, information, attention -->
						<br />
						<small>您的小组的名称</small>
					</p>
					
					<p>
						<label>所属的课程</label> <select name="dropdown"
							class="small-input">
							<option value="option1">Web 2.0——中山大学</option>
							<option value="option2">Web 2.0——MIT</option>
							<option value="option3">Web 2.0——Stanford</option>
						</select>
						<br />
						<small>您的小组属于的课程名称</small>
					</p>
					
					<p>
						<label>小组简介</label>
						<textarea class="text-input textarea medium-input required" id="textarea"
							name="introduction" cols="79" rows="15"></textarea>
						<br />
						<small>简单的描述下您的小组</small>
					</p>
					<p>
						<input class="button" type="submit" value="创建" />
					</p>

				</fieldset>

				<div class="clear"></div>
				<!-- End .clear -->

			</form>

		</div>
		<!-- End #tab3 -->

	</div>
	<!-- End .content-box-content -->

</div>
<!-- End .content-box -->

<script type="text/javascript" >


$('#create-group-form').validate();
$('#create-group-form').ajaxForm({
    // dataType identifies the expected content type of the server response
    dataType: 'json',

    // success identifies the function to invoke when the server response
    // has been received
    success:function(json)
    {
    	if(json.error)
    		{
    			if(json.error_type=="GroupNameDuplication")
					Boxy.alert("组名已经存在，请更换另一个", function() {}, {title: '错误'});
    			else
    				Boxy.alert("创建错误，请检查您的信息\n"+json.error_type+json.error, function() {}, {title: '错误'});
    		}
    	else
    		Boxy.alert("小组创建成功", function() {
    			$('#main-content').load('my_group')
    		}, {title: '成功'});
    }
});
</script>
{% endblock %}



